﻿using System;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;

namespace TaskDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Task task1 = new Task(() =>
            {
                for (int i = 0; i < 5; i++)
                {
                    Console.WriteLine("Task 1 - iteration {0}", i);
                    Task.Delay(1000);
                }
                Console.WriteLine("Task 1 complete");
                return;
            });
            task1.Start();
            task1.Wait();
            return;
            Task task2 = new Task(() => {
                Console.WriteLine("Task 2 complete");
            });
            task2.Start();
            Console.WriteLine("等待任务完成。");
            Task.WaitAll(task1, task2);
            Console.WriteLine("任务完成。");
            Console.ReadLine();
        }
    }
}
